package ip.controller;
/***********************************************************************
 * Module:  PrepareCreateCountryController.java
 * Author:  mojsilo
 * Purpose: Defines the Class PrepareCreateCountryController
 ***********************************************************************/

import ip.dto.UserDTO;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @web.servlet
 * 	name="PrepareCreateCountryController"
 * @web.servlet-mapping 
 * 	url-pattern="/control/PrepareCreateCountry"
 */
public class PrepareCreateCountryController extends HttpServlet
{

	private static final long serialVersionUID = -1458291391834246230L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
	{
		UserDTO adminFromSession;
		HttpSession session = request.getSession(true);
		adminFromSession = (UserDTO) session.getAttribute("administrator");
		if(adminFromSession == null){
			response.sendRedirect(response.encodeRedirectURL("../jsp/login_administrator.jsp"));
			return;
		}
		getServletConfig().getServletContext().getRequestDispatcher("/WEB-INF/jsp/administrator/add_country.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
	{
		doGet(request, response);
	}

}